package com.fr.cell;

import com.fr.base.core.GraphHelper;
import com.fr.cell.core.GridRowMouseHandler;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FontMetrics;
import javax.swing.ActionMap;
import javax.swing.InputMap;

public class GridRow extends BaseGridComponent
{
  public static final int ROW_WEIGHT_AJUST = 4;
  private Color separatorLineColor = new Color(172, 168, 153);
  private Color selectedForeground = Color.black;
  private Color selectedBackground = new Color(253, 216, 153);
  private GridCRRenderer gridCRRender;

  public GridRow()
  {
    GridRowMouseHandler localGridRowMouseHandler = new GridRowMouseHandler(this);
    addMouseListener(localGridRowMouseHandler);
    addMouseMotionListener(localGridRowMouseHandler);
    this.gridCRRender = new DefaultGirdRowRenderer();
    getInputMap().clear();
    getActionMap().clear();
    setFocusable(false);
    setOpaque(true);
    setUI(new GridRowUI());
  }

  public Color getBackground()
  {
    return super.getBackground();
  }

  public void setBackground(Color paramColor)
  {
    super.setBackground(paramColor);
  }

  public Color getForeground()
  {
    return super.getForeground();
  }

  public void setForeground(Color paramColor)
  {
    super.setForeground(paramColor);
  }

  public Color getSeparatorLineColor()
  {
    return this.separatorLineColor;
  }

  public void setSeparatorLineColor(Color paramColor)
  {
    Color localColor = this.separatorLineColor;
    this.separatorLineColor = paramColor;
    firePropertyChange("separatorLineColor", localColor, this.separatorLineColor);
    repaint();
  }

  public Color getSelectedForeground()
  {
    return this.selectedForeground;
  }

  public void setSelectedForeground(Color paramColor)
  {
    Color localColor = this.selectedForeground;
    this.selectedForeground = paramColor;
    firePropertyChange("selectedForeground", localColor, this.selectedForeground);
    repaint();
  }

  public Color getSelectedBackground()
  {
    return this.selectedBackground;
  }

  public void setSelectedBackground(Color paramColor)
  {
    Color localColor = this.selectedBackground;
    this.selectedBackground = paramColor;
    firePropertyChange("selectedBackground", localColor, this.selectedBackground);
    repaint();
  }

  public Dimension getPreferredSize()
  {
    ReportPane localReportPane = getReportPane();
    if (!(localReportPane.isRowHeaderVisible()))
      return new Dimension(0, 0);
    int i = caculateMaxCharNumber(localReportPane);
    return new Dimension(i * GraphHelper.getFontMetrics(getFont()).charWidth('M'), super.getPreferredSize().height);
  }

  private int caculateMaxCharNumber(ReportPane paramReportPane)
  {
    int i = 5;
    i = Math.max(i, "" + (paramReportPane.getGrid().getVerticalValue() + paramReportPane.getGrid().getVerticalExtent()).length() + 1);
    return i;
  }

  public GridCRRenderer getGridCRRender()
  {
    return this.gridCRRender;
  }

  public void setGridCRRender(GridCRRenderer paramGridCRRenderer)
  {
    this.gridCRRender = paramGridCRRenderer;
  }
}